<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .search{
            width: 200px;
            position: relative;
            margin: 100px;
        }
        .con {
            display: none;
            top: -30px;
            position: absolute;
            width: 180px;
            height: 30px;
            background-color: #fff;
            border: 1px solid #ccc;
            box-shadow: 1px 3px 3px rgba(0, 0, 0, .2);
            line-height: 30px;
            
        }
        .con::after {
            content: '';
            position: absolute;
            width: 0;
            height: 0;
            top: 30px;
            border: 8px solid #000;
            border-style: solid ;
            border-color: #fff transparent transparent;
        }
    </style>
</head>
<body>
    <div class="search">
        <div class="con">
           123
        </div>
        <input type="text">
    </div>
    <script>
        var inp = document.querySelector('input')
        var con = document.querySelector('.con')
        inp.addEventListener('keyup',function(){
                   if(this.value == ''){
                        con.style.display = 'none'
                   }
                   else{
                  con.style.display = 'block'
                  con.innerText = this.value
                   }
        })
        inp.addEventListener('blur',function(){
            con.style.display = 'none'
        })
        inp.addEventListener('focus',function(){
            if(this.value == ''){
                con.style.display = 'none'
                return;
            }
            con.style.display = 'block'
        })

    </script>
</body>
</html>